package com.wyc.service.impl;

import com.wyc.service.MonitorService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author
 */
@Service
public class MonitorServiceImpl implements MonitorService {

    private Random random = new Random();

    @Override
    public void methodA() {
        System.out.println("call methodA ...");
        sleepRandomTime();
    }

    @Override
    public void methodB() {
        System.out.println("call methodB ...");
        sleepRandomTime();
    }

    @Override
    public void methodC() {
        System.out.println("call methodC ...");
        sleepRandomTime();
    }

    private void sleepRandomTime(){
        int time = random.nextInt(100);
        try {
            TimeUnit.MILLISECONDS.sleep(time);
        } catch (InterruptedException e) {
            System.out.println("Thread sleep exception!");
        }
    }
}
